package top.zy.search.dto;

import lombok.Data;

import java.util.Map;

/**
 * @Author: HouZeYu
 * @Description:
 * @Date: Created in 14:03 2019/7/4
 */
@Data
public class SearchRequest {
    private Map<String,String> filter;//过滤条件
    private String key; //搜索字段
    private Integer page; //当前页
    private static final int DEFAULT_SIZE=20; //默认每页大小
    private static final int DEFAULT_PAGE=0; //默认当前页

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Integer getPage() {
        if (page==null){
            return DEFAULT_PAGE;
        }
        if (page==1){
            return 0;
        }else if (page>=1){
           return (page-1)*DEFAULT_SIZE;
        }else {
            return Math.max(DEFAULT_PAGE,page);
        }
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public  int getSize() {
        return DEFAULT_SIZE;
    }
}
